//package com.yunhe.device.controller.device;
//
//import com.yunhe.device.domain.device.DeviceTree;
//import com.yunhe.common.model.ResultObject;
//import com.yunhe.device.service.device.DeviceTreeService;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiImplicitParams;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.Optional;
//
//@Api(value = "deviceTree", description = "设备树形维护", tags = {"Model_DeviceTree"})
//@RequestMapping("/deviceTree")
//@RestController
//public class DeviceTreeController {
//
//    @Autowired
//    private DeviceTreeService deviceTreeService;
//
//    @ApiOperation("新增设备树形节点")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "stationCode", value = "电站代码", required = true, dataType = "long", paramType = "query"),
//            @ApiImplicitParam(name = "devCode", value = "设备代码", required = true, dataType = "long", paramType = "query"),
//            @ApiImplicitParam(name = "parentId", value = "父节点ID", dataType = "long", paramType = "query")
//    })
//    @RequestMapping(method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> create(
//            @RequestParam("stationCode") Long stationCode,
//            @RequestParam("devCode") Long devCode,
//            @RequestParam("parentId") Optional<Long> parentId) {
//        DeviceTree deviceTree = deviceTreeService.create(stationCode, devCode, parentId.orElse(null));
//        return new ResponseEntity<>(new ResultObject<>(deviceTree), HttpStatus.OK);
//    }
//
//    @ApiOperation("删除设备树形节点")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "节点ID", dataType = "long", paramType = "query")
//    })
//    @RequestMapping(method = RequestMethod.DELETE)
//    public ResponseEntity<ResultObject> update(
//            @RequestParam("id") Long id) {
//        deviceTreeService.delete(id);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }
//
//    @ApiOperation("修改设备树形节点")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "rootId", value = "根节点ID", dataType = "long", paramType = "query"),
//            @ApiImplicitParam(name = "parentId", value = "父节点ID", dataType = "long", paramType = "query"),
//            @ApiImplicitParam(name = "childId", value = "子节点ID", dataType = "long", paramType = "query")
//    })
//    @RequestMapping(method = RequestMethod.PUT)
//    public ResponseEntity<ResultObject> update(
//            @RequestParam("id") Long id,
//            @RequestParam("deviceId") Long deviceId,
//            @RequestParam("parentId") Optional<Long> parentId) {
//        deviceTreeService.update(id, deviceId, parentId.orElse(null));
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }
//
//    @ApiOperation("查询设备树形")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "stationCode", value = "电站代码", dataType = "long", paramType = "query")
//    })
//    @RequestMapping(method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> search(
//            @RequestParam("stationCode") Optional<Long> stationCode) {
//        Iterable<DeviceTree> deviceTree = deviceTreeService.search(stationCode.orElse(null));
//        return new ResponseEntity<>(new ResultObject<>(deviceTree), HttpStatus.OK);
//    }
//}
